from django.http import HttpRequest
from app.models.categoryModel import Category
from app.tools import response, url

def many(request: HttpRequest):
    categories = Category.objects.all().values()
    for category in categories:
        category['img'] = url(category['img'])

    data = list(categories)
    return response(data = data)

def one(request:HttpRequest, id:int):
    category = Category.objects.get(id = id).to_json()
    category['img'] = url(category['img'])
    return response(category)
